package com.grgbanking.it.common;

import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

/**
 * 日志记录切面
 * @author pgwei
 *
 */
@Component  
@Aspect  
public class LogAspect {
	private Logger logger = Logger.getLogger(LogAspect.class);
	private String msg = null ;

	@Around("execution(* com.grgbanking.it.*.service.*.*(..))") 
    public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
    	Object result=null;
		try{  
			result = pjp.proceed();  
		}catch(Exception e){  
			msg = "方法："+pjp.getTarget().getClass() + "." + pjp.getSignature().getName()+ "()  \n";
			msg = msg+"错误信息如下：["+e+"]";
			logger.error(msg); 
			throw e;
		}
  
        return result;
    }
}